package com.mountainreacher.automata;

import com.mountainreacher.automata.R;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

public class HowtoActivity extends Activity implements OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_howto);
		((ImageView)findViewById(R.id.rateImage)).setOnClickListener(this);
		((ImageView)findViewById(R.id.commentImage)).setOnClickListener(this);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		//		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		return true;
	}
	
	@Override
	public void onClick(View view) {
		switch (view.getId()) {
		
		case R.id.commentImage:
			Intent i = new Intent(Intent.ACTION_SEND);
			i.setType("message/rfc822");
			i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"mountainreacher@gmail.com"});
			i.putExtra(Intent.EXTRA_SUBJECT, "Feedback - Fitine State Machine");
			i.putExtra(Intent.EXTRA_TEXT, "The version I'm using is "+MenuActivity.AUTOMATA_VERSION+"\n\n");
			try {
				startActivity(Intent.createChooser(i, "Send mail"));
			} catch (android.content.ActivityNotFoundException ex) {
				Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
			}
			break;
			
		case R.id.rateImage:
			Intent link = new Intent(Intent.ACTION_VIEW);
			link.setData(Uri.parse("market://details?id=com.mountainreacher.automata"));
			startActivity(link);
			break;

		default:
			break;
		}
	}

	// **************************************** APP LIFE CYCLE ***************************************

	@Override
	public void onPause() {
		super.onPause();
	}

	@Override
	public void onResume() {
		super.onResume();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

	// **************************************** APP LIFE CYCLE ***************************************

}
